cFader = { speed : 40, steps : 8, active : 0, startc : 0, endc : 0, startr : 0, startg : 0, startb : 0, endr : 0, endg : 0, endb : 0, startColor1 : '#000000', endColor1 : '#9697C9' } cFader.colorToNumber = function( sColor ) { sRCol = /^#/ return parseInt( '0x'+sColor.replace( sRCol, '' ) ) } cFader.numberToColor = function( nColor ) { nColor |= 1<<24 return '#'+nColor.toString(16).substr(1) } cFader.init = function( element ) { if (element.className == "leftcategory") { SC = this.startColor1; EC = this.endColor1; } with (this) { startc = colorToNumber( SC ) endc = colorToNumber( EC ) startr = (startc & 0xff0000) >>> 16 startg = (startc & 0x00ff00) >>> 8 startb = (startc & 0x0000ff) endr = (endc & 0xff0000) >>> 16 endg = (endc & 0x00ff00) >>> 8 endb = (endc & 0x0000ff) } } cFader.fadeIn = function( element ) { this.init( element ) elName = 'cFaderActive'+(this.active++) eval( 'this.'+elName+'=element' ) for( step = 0; step <= this.steps; step++ ) { with( this ) { nColor = startr*((steps-step)/steps)+endr*(step/steps) << 16 | startg*((steps-step)/steps)+endg*(step/steps) << 8 | startb*((steps-step)/steps)+endb*(step/steps) } sColor = this.numberToColor( nColor ) setTimeout('cFader.doFade("'+elName+'", "'+sColor+'")', this.speed*(step+1)) } } cFader.fadeOut = function( element ) { this.init( element ) elName = 'cFaderActive'+(this.active++) eval( 'this.'+elName+'=element' ) for( step = 0; step <= this.steps; step++ ) { with( this ) { nColor = endr*((steps-step)/steps)+startr*(step/steps) << 16 | endg*((steps-step)/steps)+startg*(step/steps) << 8 | endb*((steps-step)/steps)+startb*(step/steps) } sColor = this.numberToColor( nColor ) setTimeout('cFader.doFade("'+elName+'", "'+sColor+'")', this.speed*(step+1)) } } cFader.doFade = function( elName, sColor ) { element = eval( 'this.'+elName ) element.style.color = sColor } //get real element that originated the event function getReal( e ) { elm = ( e.srcElement ) ? e.srcElement : e.originalTarget.parentNode if ((elm.tagName.toUpperCase() == "A") && elm.className == "leftcategory") return elm else return null } //activation function fadeMouseOver( e ) { eSrc = window.event.srcElement; if (eSrc) { if (eSrc.className == "leftcategory") { if (!e) e = window.event element = getReal(e) if (element != null) cFader.fadeIn(element) } } } //deactivation function fadeMouseOut( e ) { eSrc = window.event.srcElement; if (eSrc) { if (eSrc.className == "leftcategory") { if (!e) e = window.event element = getReal( e ) if( element != null ) cFader.fadeOut( element ) } } } if( document.attachEvent ) { document.attachEvent( 'onmouseover', fadeMouseOver ) document.attachEvent( 'onmouseout', fadeMouseOut ) } else if( document.addEventListener ) { document.addEventListener( 'mouseover', fadeMouseOver, true ) document.addEventListener( 'mouseout', fadeMouseOut, true ) } else if( document.all ) { document.onmouseover = fadeMouseOver document.onmouseout = fadeMouseOut }